package com.ethink.warehouse.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ethink.framework.common.db.PageUtils;
import com.ethink.id.generator.IdGenerator;
import com.ethink.warehouse.api.info.LogisticsTraceDetailOrderInfo;
import com.ethink.warehouse.api.request.LogisticsTraceDetailOrderListRequest;
import com.ethink.warehouse.api.request.LogisticsTraceDetailOrderQueryRequest;
import com.ethink.warehouse.api.request.LogisticsTraceDetailOrderUpdateRequest;
import com.ethink.warehouse.api.response.LogisticsTraceDetailOrderDeleteResponse;
import com.ethink.warehouse.api.response.LogisticsTraceDetailOrderUpdateResponse;
import com.ethink.warehouse.common.entity.LogisticsTraceDetailOrder;
import com.ethink.warehouse.common.mapper.LogisticsTraceDetailOrderMapper;
import com.ethink.warehouse.common.mapper.SubWarehouseMapper;
import com.ethink.warehouse.converter.LogisticsTraceDetailOrderConverter;
import com.ethink.warehouse.service.LogisticsTraceDetailOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 入库/出库单 Service接口实现
 *
 * @author default
 * @date 2022-11-10
 */
@Slf4j
@Service
public class LogisticsTraceDetailOrderServiceImpl extends ServiceImpl<LogisticsTraceDetailOrderMapper, LogisticsTraceDetailOrder> implements LogisticsTraceDetailOrderService {

    @Autowired
    private LogisticsTraceDetailOrderMapper logisticsTraceDetailOrderMapper;

    @Autowired
    private LogisticsTraceDetailOrderConverter logisticsTraceDetailOrderConverter;

    @Autowired
    private SubWarehouseMapper subWarehouseMapper;

    @Autowired
    private IdGenerator idGenerator;

    @Override
    public Page<LogisticsTraceDetailOrderInfo> queryLogisticsTraceDetailOrder(LogisticsTraceDetailOrderQueryRequest request) {
        return logisticsTraceDetailOrderMapper.queryLogisticsTraceDetailOrder(PageUtils.buildPage(request), request);
    }

    @Override
    public LogisticsTraceDetailOrderInfo getLogisticsTraceDetailOrderById(Long logisticsTraceDetailOrderId) {
        return logisticsTraceDetailOrderMapper.getLogisticsTraceDetailOrderById(logisticsTraceDetailOrderId);
    }

    @Override
    public List<LogisticsTraceDetailOrderInfo> listLogisticsTraceDetailOrder(LogisticsTraceDetailOrderListRequest request) {
        return logisticsTraceDetailOrderMapper.listLogisticsTraceDetailOrder(request);
    }


    @Override
    public LogisticsTraceDetailOrderUpdateResponse updateLogisticsTraceDetailOrder(LogisticsTraceDetailOrderUpdateRequest request) {
        LogisticsTraceDetailOrderUpdateResponse response = new LogisticsTraceDetailOrderUpdateResponse();
//        LambdaUpdateWrapper<LogisticsTraceDetailOrder> updateWrapper = new LambdaUpdateWrapper<>();
//        updateWrapper.eq(LogisticsTraceDetailOrder::getId, request.getId());
//        // FIXME 按实际业务需求set
//        updateWrapper.set(LogisticsTraceDetailOrder::getDetailOrderNo, request.getDetailOrderNo());
//        updateWrapper.set(LogisticsTraceDetailOrder::getLogisticsTraceOrderNo, request.getLogisticsTraceOrderNo());
//        updateWrapper.set(LogisticsTraceDetailOrder::getOrderType, request.getOrderType());
//        updateWrapper.set(LogisticsTraceDetailOrder::getOrderStatus, request.getOrderStatus());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSourceOrderNo, request.getSourceOrderNo());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSourceDetailOrderNo, request.getSourceDetailOrderNo());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSourceOrderType, request.getSourceOrderType());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSubject, request.getSubject());
//        updateWrapper.set(LogisticsTraceDetailOrder::getMateSku, request.getMateSku());
//        updateWrapper.set(LogisticsTraceDetailOrder::getProduceCode, request.getProduceCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getInventoryType, request.getInventoryType());
//        updateWrapper.set(LogisticsTraceDetailOrder::getPurchaseOrderNo, request.getPurchaseOrderNo());
//        updateWrapper.set(LogisticsTraceDetailOrder::getPurchaseDetailOrderNo, request.getPurchaseDetailOrderNo());
//        updateWrapper.set(LogisticsTraceDetailOrder::getApplyInQty, request.getApplyInQty());
//        updateWrapper.set(LogisticsTraceDetailOrder::getActualApplyInQty, request.getActualApplyInQty());
//        updateWrapper.set(LogisticsTraceDetailOrder::getActualInQty, request.getActualInQty());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSourceSubWarehouseCode, request.getSourceSubWarehouseCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSourceSubWarehouseName, request.getSourceSubWarehouseName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getTargetSubWarehouseCode, request.getTargetSubWarehouseCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getTargetSubWarehouseName, request.getTargetSubWarehouseName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCreateUserCode, request.getCreateUserCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCreateUserName, request.getCreateUserName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getMateCode, request.getMateCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getMateName, request.getMateName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getMateSkuName, request.getMateSkuName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getGeneraCode, request.getGeneraCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getMinorDefectsCode, request.getMinorDefectsCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getSubclassCode, request.getSubclassCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCategoryName, request.getCategoryName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getBrandCode, request.getBrandCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getBrandName, request.getBrandName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getInternationCode, request.getInternationCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getUnitCode, request.getUnitCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getUnitName, request.getUnitName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getProductSpecification, request.getProductSpecification());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCountryOfOrigin, request.getCountryOfOrigin());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCompanyCode, request.getCompanyCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCompanyName, request.getCompanyName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCurrencyCode, request.getCurrencyCode());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCurrencyName, request.getCurrencyName());
//        updateWrapper.set(LogisticsTraceDetailOrder::getOperateTime, request.getOperateTime());
//        updateWrapper.set(LogisticsTraceDetailOrder::getProductDate, request.getProductDate());
//        updateWrapper.set(LogisticsTraceDetailOrder::getExpireDate, request.getExpireDate());
//        updateWrapper.set(LogisticsTraceDetailOrder::getCostPrice, request.getCostPrice());
//        logisticsTraceDetailOrderMapper.update(null, updateWrapper);
        return response;
    }

    @Override
    public LogisticsTraceDetailOrderDeleteResponse deleteLogisticsTraceDetailOrder(Long logisticsTraceDetailOrderId) {
        LogisticsTraceDetailOrderDeleteResponse response = new LogisticsTraceDetailOrderDeleteResponse();
//        LambdaUpdateWrapper<LogisticsTraceDetailOrder> updateWrapper = new LambdaUpdateWrapper<>();
//        updateWrapper.eq(LogisticsTraceDetailOrder::getId, logisticsTraceDetailOrderId);
//        updateWrapper.set(LogisticsTraceDetailOrder::getIsDeleted, true);
//        logisticsTraceDetailOrderMapper.update(null, updateWrapper);
        return response;
    }

}
